home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_054 / miditools / play.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  54 lines

  1. /****************************************************************************
  2.   
  3.    Author:  Fred Cassirer
  4.    Date:    January 24, 1987
  5.    
  6.    This program is placed in the public domain, and from what I understand
  7.    that means anyone can do whatever they want with it.   That's fine 
  8.    because they are fairly trivial anyway ...  If you can get someone to pay
  9.    you for them, you must be doing something right.
  10.  
  11.  ****************************************************************************/
  12. #include "stdio.h"
  13. #include "exec/types.h"
  14. #include "midi.h"
  15.  
  16. #undef GETMIDI
  17. #define GETMIDI(t) if (scanf("%x",&t) != 1) t = NON_MIDI_EVENT;
  18.  
  19. main()
  20. {
  21.  FILE *fp;
  22.  int i=0;
  23.  int midi,timetag;
  24.  
  25.  if ( (fp=fopen("ser:31250,n,8,1","w")) == NULL) {
  26.     printf("Could not open serial port for write!/n");
  27.     exit(1);
  28.  }
  29.  
  30.  GETMIDI(midi); /* First stuff is bogus timetag */
  31.  GETMIDI(midi); /* Eat timetag .. munch .. munch crunch */
  32.   
  33.  GETMIDI(midi); /* First true midi stuff */
  34.  
  35.  while (midi != NON_MIDI_EVENT) {
  36.  
  37.     if ( midi == TIMETAG ) {
  38.        GETMIDI(timetag);
  39.        if ( timetag ) {
  40.            Delay( (long) timetag  ); /* 60th's of second */
  41.        }
  42.  
  43.       GETMIDI(midi);
  44.     }
  45.     else 
  46.      do {
  47.          putc(midi,fp);           
  48.          GETMIDI(midi);
  49.      } while ( ( midi != TIMETAG) && ( midi != NON_MIDI_EVENT) );
  50.  
  51.  }
  52.  
  53. }
  54.